package com.itheima.day2.exercise;

import java.util.List;
import java.util.function.Consumer;

public class Exercise3 {

    static void consume(List<Integer> list) {
        for (Integer number : list) {
            // 消费：打印，但以后可能改变消费规则
            // (Integer number) -> System.out.println(number)
            System.out.println(number);
        }
    }

    static void consume(List<Integer> list, Consumer<Integer> consumer) {
        for (Integer number : list) {
            // 消费：打印，但以后可能改变消费规则
            consumer.accept(number);
        }
    }

    public static void main(String[] args) {
        consume(List.of(1, 2, 3, 4, 5), (Integer number) -> System.out.println(number));
    }

}
